package com.hue.springbooteasyexcel.utils;

import com.hue.springbooteasyexcel.connector.ImportExcel;
import com.hue.springbooteasyexcel.domain.LineLossAnalyzeExcelVo;
import com.hue.springbooteasyexcel.domain.User;
import com.hue.springbooteasyexcel.service.CourtsService;
import com.hue.springbooteasyexcel.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 姚凤桥
 * @Date 2022/1/18 11:17
 * @Description:
 */
@Component
public class ImportExcels {
    @Autowired
    private UserService userService;
    @Autowired
    private CourtsService courtsService;

    private Map<Class, ImportExcel> map = new HashMap<>();

    @PostConstruct
    public void init() {
        map.put(User.class, (ImportExcel) userService);
        map.put(LineLossAnalyzeExcelVo.class, (ImportExcel) courtsService);
    }

    public ImportExcel getExcelImport(Class aClass) {
        return map.get(aClass);
    }
}
